#include <iostream>
#include <string>
#include <vector>
#include "FileLoader.h"
#include "Lamarckian.h"
#include "Baldwinian.h"
#include "InitialRandomPopulation.h"
#include "InitialHalfGoodPopulation.h"
#include "RankingSelection.h"
#include "RandomSelection.h"
#include "LOX.h"
#include "OX.h"
#include "PMX.h"
#include "MutationInsertion.h"
#include "MutationInverse.h"
#include "MutationSwap.h"
#include "II.h"
#include "SimulatedAnnealing.h"
#include "EnvironmentSelectionNPlusNMechanism.h"
#include "EnvironmentSelectionSteadyStateModel.h"
#include "EnvironmentSelectionGenerationalModel.h"
using namespace std;

int main(){
	string text[] = 
		{ "tai20_5_1.txt", "tai20_10_1.txt", "tai20_20_1.txt",
		  "tai50_5_1.txt", "tai50_10_1.txt", "tai50_20_1.txt",
		  "tai100_5_1.txt", "tai100_10_1.txt", "tai100_20_1.txt" };
	
	
	for( int timen = 1 ; timen <= 20 ; ++timen ){
		Evaluation::Times = timen;
	for( int filen = 0 ; filen < 9 ; ++filen ){
		FileLoader::Load( text[filen] );
		InitialPopulationFactory *ipf[2] = 
			{ new InitialRandomPopulation(Evaluation::GetJobNum()),
			  new InitialHalfGoodPopulation(Evaluation::GetJobNum(), new II() ) };
		MatingSelection *ms[2] =
			{ new RandomSelection(), new RankingSelection() };
		Crossover *co[3] =
			{ new LOX(), new OX(), new PMX() };
		Mutation *mut[3] =
			{ new MutationSwap(), new MutationInsertion(), new MutationInverse() };
		LocalSearch *ls[2] =
			{ new II(), new SimulatedAnnealing() };
		EnvironmentSelection *es[3] =
			{ new EnvironmentSelectionGenerationalModel(), 
			  new EnvironmentSelectionNPlusNMechanism(), 
			  new EnvironmentSelectionSteadyStateModel() };
	for( int ipfn = 0 ; ipfn < 2 ; ++ipfn )
	for( int msn = 0 ; msn < 2 ; ++msn )
	for( int con = 0 ; con < 3 ; ++con )
	for( int mutn = 0 ; mutn< 3 ; ++mutn )
	for( int lsn = 0 ; lsn < 2 ; ++lsn )
	for( int esn = 0 ; esn < 3 ; ++esn ){
		Baldwinian( ipf[ipfn], ms[msn], con[co], mut[mutn], ls[lsn], es[esn] ).Run();
		Lamarckian( ipf[ipfn], ms[msn], con[co], mut[mutn], ls[lsn], es[esn] ).Run();
	}
		delete ipf[0];
		delete ipf[1];
		delete ms[0];
		delete ms[1];
		delete co[0];
		delete co[1];
		delete co[2];
		delete mut[0];
		delete mut[1];
		delete mut[2];
		delete ls[0];
		delete ls[1];
		delete es[0];
		delete es[1];
		delete es[2];
	}
	}
	return 0;
}